<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use App\Http\Model\FinanceWithdrawOrder;
use App\Http\Model\Mall;
use App\Http\Services\ApiServices;

class SendDiamondToUserCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'SendDiamondToUserCommand';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '批量给用户发钻石';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        do {
            //赠送500钻用户
            $userIds_1 = [
                40301,
                19691,
                65275,
                36073,
                29882,
                16288,
                22958,
                69450,
                16891,
                36530,
                102199,
                76171,
            ];
            // //8月份累计充值大于3万
            // $userIds_2 = [
            //     22133,
            //     11220,
            //     11841,
            //     27260,
            //     18410,
            //     14733,
            // ];
            //送100钻
            
            $userIds_3 = [
                71783,47625,91944,70368,20711,71781,99082,22868,18962,13521,44248,74018,66433,67243,66869,27994,98937,72576,92666,46369,80533,21543,67392,45361,26070,13265,20871,13281,14733,36894,37849,85586,74692,81139,25456,50285,48845,10118,27844,16287,61339,19592,28579,88372,14859,48332,61074,92018,13296,72205,28422,47005,75523,54600,65098,98459,56447,93769,21482,99783,14383,62563,58034,29493,48394,61380,13295,42713,83261,16912,60711,30631,15207,17342,14333,10074,69439,24393,47543,33291,20028,32847,50377,39696,41813,72557,55019,44205,66734,82929,24253,103415,60643,27909,19822,68765,88819,11220,20714,51171,13523,93195,59430,37244,41743,69537,13069,71761,54329,61821,53705,44141,46821,69468,10374,72246,22933,96049,87069,92746,20995,35341,48631,19800,25454,21294,67079,20503,69160,37449,31005,65343,13546,15026,21075,11560,22881,86025,13715,95487,14567,31996,26914,71793,11525,64541,72267,85816,69305,64873,14502,69171,19729,23484,45300,10435,78182,16464,40649,86321,99884,97119,68718,10009,14615,13045,35735,49873,19832,14899,55049,14526,53367,78620,12928,68305,65035,25532,80252,77086,12952,41146,80453,89483,42688,70406,20339,16219,78608,101642,44755,11856,79715,15033,26418,101663,94549,79159,95802,68613,14024,28532,32770,21594,94640,22133,52524,19513,39739,15869,41797,62197,31353,21201,59669,100612,19679,78616,28354,24246,96579,36360,65448,106741,88242,67489,21662,94987,13173,63280,43363,38478,71654,12598,92564,90800,60192,14047,13381,17271,42767,10714,88174,90022,67315,32883,68804,62769,14856,71342,19401,82528,62816,32846,41291,82199,86397,65643,98671,20331,54226,57494,70079,62457,19472,78044,20539,38432,51042,80506,21300,48435,80213,41344,48321,34581,55995,101375,21320,66544,32851,83881,102984,12978,18703,41426,22229,22648,60465,65857,76300,56841,19057,90885,90315,38145,66821,69858,52808,40190,40274,47510,42262,31477,72603,68688,95488,53042,53365,36381,97038,29505,39611,71344,96412,16887,18873,47456,79678,32517,106821,78086,52585,85262,28754,65546,21376,73729,74474,65333,64952,87088,22256,40929,52218,19870,19959,19529,67949,19738,21568,70692,69659,49398,57546,103884,60122,23653,39485,65046,35359,54924,75502,58245,100579,22575,63147,87794,82538,25197,19737,41222,19672,66934,59151,73506,19418,60628,95068,72842,38862,63245,17242,49529,35440,42012,19165,35771,88304,59850,31988,52381,65725,68764,95239,53860,69962,62776,61459,99209,23217,25531
            ];

            //测试
            // $userIds_1 = [10001,10002];
            // $userIds_2 = [10001,10002];
            // $userIds_3 = [10001,10002];

            //500钻
            $this->_userSendDiamond($userIds_1, 500);
            //8月份累计充值大于3万
            //$this->_userSendDiamond($userIds_2, 3000);
            //100钻
            $this->_userSendDiamond($userIds_3, 100);

        } while (false);
    }
    //用户批量发钻石
    public function _userSendDiamond($userIds, $amount)
    {
        $apiServices = new ApiServices();

        foreach($userIds as $userId) {
            $apiServices->increase($userId, 4, $amount, '后台赠送钻石'.$amount.'钻');
            echo '发钻石完成 用户 '.$userId.' 数量 '.$amount."\n";
        }
    }

    //返回数组
    public function objToArray($document)
    {
        return json_decode(json_encode($document), true);
    }

}